$(document).ready(function(){
	$('#lform').submit(function(){
		var password = $('#password').fieldValue();
		var username = $('#username').fieldValue();
		$('input').focus(function() {
			$('#login_msg').empty();
		});
		if (username != '' && password != '') {
			$.post("/login/check",{'u': username, 'p': password} ,function(data) {
				if (data.r == "succ") {
					window.location = "/welcome";
				} else {
					$("#login_msg").html("Login failed, please retry ~");
				}
			}, 'json');
		} else {
			$("#login_msg").html("Login failed, please retry ~");
		}
		return false;
	});
});
